<?php

class Home_ArticleController extends Ext_Controller_Action_Front
{
    public function init()
    {
        parent::init();
    }
    

    public function myAttentionAction()
    {
        $userId = Ext_Auth_Front::getInstance()->getIdentity();

        $author = Ext_User::getInstance()->show($userId)->buildAvatar()->buildUrl();
        
        $count = App_Model_Article::getInstance()->getMyHomeCount($userId);
        $list  = App_Model_Article::getInstance()->getMyHomeList($userId);
        $adapter = new Zend_Paginator_Adapter_DbSelect($list);
        $adapter->setRowCount($count);
        $paginator = new Zend_Paginator($adapter);
        $paginator
              //->setCurrentPageNumber(1)
              ->setItemCountPerPage(12)
              ->setCurrentPageNumber($this->_getParam('page'))
            //->setDefaultPageRange(20)
            ;
        $articles = array();
        foreach ($paginator as $key=>$item)
        {
            $articleId = $item['articleId'];
            
            $article = Ext_Article::getInstance()->show($articleId)->isExcerpt()->buildDescription()->buildAttachemnts()->buildTags()->buildFamily();
            
            $articles[] = $article;
        }
        
        
        $this->view->author    = $author;
        $this->view->articles  = $articles;
        $this->view->paginator = $paginator;
    }
    
    public function myCreationAction()
    {
        $userId = Ext_Auth_Front::getInstance()->getIdentity();
        
        $author = Ext_User::getInstance()->show($userId)->buildAvatar()->buildUrl();
        
        $count = App_Model_Article::getInstance()->getMyBlogCount($userId);
        $list  = App_Model_Article::getInstance()->getMyBlogList($userId);
        $adapter = new Zend_Paginator_Adapter_DbSelect($list);
        $adapter->setRowCount($count);
        $paginator = new Zend_Paginator($adapter);
        $paginator
              //->setCurrentPageNumber(1)
              ->setItemCountPerPage(12)
              ->setCurrentPageNumber($this->_getParam('page'))
            //->setDefaultPageRange(20)
            ;
        $articles = array();
        foreach ($paginator as $key=>$item)
        {
            $articleId = $item['articleId'];

            $_article = Ext_Article::getInstance()->show($articleId)->isExcerpt()->buildDescription()->buildAttachemnts()->buildTags()->buildFamily();

            $articles[] = $_article;
        }

        $this->view->author    = $author;
        $this->view->articles  = $articles;
        $this->view->paginator = $paginator;
    }
}

?>